package org.mat.ipaas.ucenter.bff.admin.modules.system;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.api.system.SysLogRestAPI;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysLogDTO;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysRoleDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 系统日志表 前端控制器
 * </p>
 *
 * @Author zhangweijian
 * @since 2018-12-26
 */
@RestController
@RequestMapping("/sys/log")
@Slf4j
public class SysLogController {
	
	@Autowired
	private SysLogRestAPI sysLogRestAPI;

	/**
	 * @功能：查询日志记录
	 * @param sysLogDTO
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public MatApiResponse<Page<SysLogDTO>> queryPageList(SysLogDTO sysLogDTO,
														 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
														 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
		MatApiResponse<Page<SysLogDTO>> matApiResponse = sysLogRestAPI.queryPageList(sysLogDTO, pageNo, pageSize);
		return matApiResponse;
	}
	
	/**
	 * @功能：删除单个日志记录
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
	public MatApiResponse<SysLogDTO> delete(@RequestParam(name="id",required=true) String id) {
		MatApiResponse<SysLogDTO> matApiResponse = sysLogRestAPI.delete(id);
		return matApiResponse;
	}
	
	/**
	 * @功能：批量，全部清空日志记录
	 * @param ids
	 * @return
	 */
	@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
	public MatApiResponse<SysRoleDTO> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		MatApiResponse<SysRoleDTO> matApiResponse = sysLogRestAPI.deleteBatch(ids);
		return matApiResponse;
	}
	
	
}
